package cn.weiron.fun.infrastructure.dto;

import org.springframework.data.domain.PageRequest;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * <p>医政卫监平台.机构纠纷应用.纠纷服务：</p>
 * <p>接口层：页码请求参数</p>
 *
 * @author 马强
 */
public class PageRequestDto {
    @NotNull(message = "必须指定当前的页码")
    private Integer pageIndex = 1;

    @NotNull(message = "必须指定当前每页的数量")
    @Min(value = 0L, message = "每页数量必须大于0")
    @Max(value = 100L, message = "每页数量不能大于100")
    private Integer pageSize = 10;

    public PageRequest to() {
        return PageRequest.of(pageIndex - 1, pageSize);
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }
}